import request from '@/utils/request.js'
/* 获取员工简单列表 */
export const getEmployeeSimple = () => {
	return request({
		url: '/sys/user/simple'
	})
}

/* 获取员工数据列表 */
export const getEmployeeList = (params) => {
	return request({
		url: '/sys/user',
		params
	})
}

/* 根据ID删除员工 */
export const delEmployee = (id) => {
	return request({
		url: `/sys/user/${id}`,
		method: 'delete'
	})
}

/* 新增员工 */
export const addEmployee = (data) => {
	return request({
		url: '/sys/user',
		method: 'post',
		data
	})
}

/* 批量导入员工 */
export const importEmployee = (data) => {
	return request({
		url: '/sys/user/batch',
		method: 'post',
		data
	})
}

/* 根据ID获取个人信息  */
export function getUserDetailById(id) {
	return request({
		url: `/sys/user/${id}`,
		method: 'get'
	})
}
/* 根据ID保存个人信息 */
export const updateUserDetailById = (id, data) => {
	return request({
		url: `/sys/user/${id}`,
		method: 'put',
		data
	})
}

/* 根据ID获取用户的详细信息 */
export const getEmpDetailById = (id) => {
	return request({
		url: `/employees/${id}/personalInfo`
	})
}
/* 根据ID保存用户的详细信息 */
export const updateEmpDetailById = (id, data) => {
	return request({
		url: `/employees/${id}/personalInfo`,
		method: 'put',
		data
	})
}

/* 根据ID获取员工岗位信息 */
export const getEmpJobDetailById = (id) => {
	return request({
		url: `/employees/${id}/jobs`
	})
}

/* 根据ID更新员工岗位信息 */
export const updateEmpJobDetailById = (id, data) => {
	return request({
		url: `/employees/${id}/jobs`,
		method: 'put',
		data
	})
}

/* 给员工分配角色 */
export const setRoleForEmp = (data) => {
	return request({
		url: '/sys/user/assignRoles',
		data,
		method: 'put'
	})
}
